package com.cw.controller;


import com.cw.annotation.OperationLogAnno;
import com.cw.common.api.*;
import com.cw.common.constant.DmlTypeConstant;
import com.cw.entity.ExtInformation;
import com.cw.service.*;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;

/**
 * @author smq
 * @since 2021-05-09
 */
@Api(tags = {"中间表"})
@RestController
@RequestMapping("/patient-bed-middle")
public class PatientBedMiddleController {

    @Autowired
    private IPatientBedMiddleService targetService;

    @ApiOperation(value = "判断是同病区同房间是否有特殊护理病人")
    @GetMapping("/determineSPD")
    public Response determineSPD(
            @RequestParam String nurseCellCode, @RequestParam String roomNo) {
        return targetService.determineSPD(nurseCellCode, roomNo);
    }

    @ApiOperation(value = "床位登记-床位ID、病人ID、病人姓名")
    @OperationLogAnno(site = "住院预约记录", operation = "未预约->已预约", bz = "门诊办人员操作",
            method = "/patient-bed-middle/addPatientBed", type = "INSERT")
    @PostMapping("/addPatientBed")
    public Response addPatientBed(
            @RequestParam String bedId, @RequestParam String patientId, @RequestParam String name) {
        return targetService.addPatientBed(bedId, patientId);
    }


    @ApiOperation(value = "转床-床位ID、病人ID、病人姓名")
    @PostMapping("/changePatientBed")
    public Response changePatientBed(
            @RequestParam String bedId,
            @RequestParam String patientId,
            @RequestParam String name, String deptCode, String deptName, String sdeptCode) {
        return targetService.changePatientBed1(bedId, patientId, deptCode, deptName, sdeptCode);
    }

    @ApiOperation(value = "取消预约-床位ID、病人ID、病人姓名")
    @PostMapping("/delPatientBed")
    @OperationLogAnno(site = "住院预约记录", operation = "已预约->取消预约", bz = "门诊办人员操作",
            method = "/patient-bed-middle/delPatientBed", type = "UPDATE")
    public Response delPatientBed(
            @RequestParam String bedId,
            @RequestParam String patientId, @RequestParam String name, @RequestParam String remark) {
        return targetService.delPatientBed(bedId, patientId, remark);
    }

    @ApiOperation(value = "获取预约超时的患者信息")
    @GetMapping("/getAppointmentTimeOut")
    public ResultObject getAppointmentTimeOut() {
        return ResultObject.successReturn(targetService.getAppointmentTimeOut());
    }

    @ApiOperation(value = "释放床位")
    @PostMapping("/updateReleaseBed")
    @OperationLogAnno(site = "住院预约记录", operation = "一键释放", bz = "门诊办人员操作",
            method = "/patient-bed-middle/updateReleaseBed", type = "UPDATE")
    public Response updateReleaseBed() {
        return targetService.updateReleaseBed();
    }


    @ApiOperation(value = "测试插入是否回滚")
    @PostMapping("/AddExtTest")
    public void AddExtTest(@RequestBody ExtInformation entity) {
        targetService.addExtTest(entity);
    }

    @ApiOperation(value = "获取取消原因")
    @GetMapping("/getCacelReson")
    public Response getCacelReson() {
        return targetService.getCacelReson();
    }
}

